package com.example.romibogesture;

import com.example.romibogesture.Bluetooth;


import android.os.Bundle;
import android.app.Activity;
import android.view.View;
import android.widget.Button;

public class MainActivity extends Activity {	

Button g1, g2, g3, g4, g5, g6, g7, g8, g9, g10, g11, g12, g13, g14, g15, g16, g17, g18, g19, g20, g21, g22, g23, g24, g25, g26, g27, g28, g29, g30;
	
	Bluetooth b = new Bluetooth();
	/** Called when the user clicks the Send button */
	
	@Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        b.connect();
        
        g1 = (Button) findViewById(R.id.g1);
        g2 = (Button) findViewById(R.id.g2);
        g3 = (Button) findViewById(R.id.g3);
        g4 = (Button) findViewById(R.id.g4);
        g5 = (Button) findViewById(R.id.g5);
        g6 = (Button) findViewById(R.id.g6);
        g7 = (Button) findViewById(R.id.g7);
        g8 = (Button) findViewById(R.id.g8);
        g9 = (Button) findViewById(R.id.g9);
        g10 = (Button) findViewById(R.id.g10);
        g11 = (Button) findViewById(R.id.g11);
        g12 = (Button) findViewById(R.id.g12);
        g13 = (Button) findViewById(R.id.g13);
        g14 = (Button) findViewById(R.id.g14);
        g15 = (Button) findViewById(R.id.g15);
        g16 = (Button) findViewById(R.id.g16);
        g17 = (Button) findViewById(R.id.g17);
        g18 = (Button) findViewById(R.id.g18);
        g19 = (Button) findViewById(R.id.g19);
        g20 = (Button) findViewById(R.id.g20);
        g21 = (Button) findViewById(R.id.g21);
        g22 = (Button) findViewById(R.id.g22);
        g23 = (Button) findViewById(R.id.g23);
        g24 = (Button) findViewById(R.id.g24);
        g25 = (Button) findViewById(R.id.g25);
        g26 = (Button) findViewById(R.id.g26);
        g27 = (Button) findViewById(R.id.g27);
        g28 = (Button) findViewById(R.id.g28);
        g29 = (Button) findViewById(R.id.g29);
        g30 = (Button) findViewById(R.id.g30);

    g1.setOnClickListener(new View.OnClickListener() {
        public void onClick(View v) {
        	if (g1.isSelected()){
        		g1.setSelected(false); 
        		
        				
        	} else {
  	        g1.setSelected(true);
  	        g2.setSelected(false); 
      		g3.setSelected(false);
      		g4.setSelected(false);
      		g5.setSelected(false);
      		g6.setSelected(false);
      		g7.setSelected(false); 
      		g8.setSelected(false);
      		g9.setSelected(false);
      		g10.setSelected(false);
      		g11.setSelected(false);
	        g12.setSelected(false); 
    		g13.setSelected(false);
    		g14.setSelected(false);
    		g15.setSelected(false);
    		g16.setSelected(false);
    		g17.setSelected(false); 
    		g18.setSelected(false);
    		g19.setSelected(false);
    		g20.setSelected(false);
    		g21.setSelected(false);
	        g22.setSelected(false); 
    		g23.setSelected(false);
    		g24.setSelected(false);
    		g25.setSelected(false);
    		g26.setSelected(false);
    		g27.setSelected(false); 
    		g28.setSelected(false);
    		g29.setSelected(false);
    		g30.setSelected(false);
      		b.callComm("1");
      		
  	            //...Handled toggle on
  	        }
        	
         }
        
        
     });
        	
	          
    g2.setOnClickListener(new View.OnClickListener() {
        public void onClick(View v) {
        	if (g2.isSelected()){
        		g2.setSelected(false); 
        		
        				
        	} else {
        		g1.setSelected(false);
      	        g2.setSelected(true); 
          		g3.setSelected(false);
          		g4.setSelected(false);
          		g5.setSelected(false);
          		g6.setSelected(false);
          		g7.setSelected(false); 
          		g8.setSelected(false);
          		g9.setSelected(false);
          		g10.setSelected(false);
          		g11.setSelected(false);
    	        g12.setSelected(false); 
        		g13.setSelected(false);
        		g14.setSelected(false);
        		g15.setSelected(false);
        		g16.setSelected(false);
        		g17.setSelected(false); 
        		g18.setSelected(false);
        		g19.setSelected(false);
        		g20.setSelected(false);
        		g21.setSelected(false);
    	        g22.setSelected(false); 
        		g23.setSelected(false);
        		g24.setSelected(false);
        		g25.setSelected(false);
        		g26.setSelected(false);
        		g27.setSelected(false); 
        		g28.setSelected(false);
        		g29.setSelected(false);
        		g30.setSelected(false);
      		b.callComm("2");
  	            //...Handled toggle on
  	        }
        	
         }
        
        
     });
        

    g3.setOnClickListener(new View.OnClickListener() {
        public void onClick(View v) {
        	if (g3.isSelected()){
        		g3.setSelected(false); 
        		
        				
        	} else {
        		g1.setSelected(false);
      	        g2.setSelected(false); 
          		g3.setSelected(true);
          		g4.setSelected(false);
          		g5.setSelected(false);
          		g6.setSelected(false);
          		g7.setSelected(false); 
          		g8.setSelected(false);
          		g9.setSelected(false);
          		g10.setSelected(false);
          		g11.setSelected(false);
    	        g12.setSelected(false); 
        		g13.setSelected(false);
        		g14.setSelected(false);
        		g15.setSelected(false);
        		g16.setSelected(false);
        		g17.setSelected(false); 
        		g18.setSelected(false);
        		g19.setSelected(false);
        		g20.setSelected(false);
        		g21.setSelected(false);
    	        g22.setSelected(false); 
        		g23.setSelected(false);
        		g24.setSelected(false);
        		g25.setSelected(false);
        		g26.setSelected(false);
        		g27.setSelected(false); 
        		g28.setSelected(false);
        		g29.setSelected(false);
        		g30.setSelected(false);
      		b.callComm("3");
  	            //...Handled toggle on
  	        }
        	
         }
        
        
     });

    g4.setOnClickListener(new View.OnClickListener() {
        public void onClick(View v) {
        	if (g4.isSelected()){
        		g4.setSelected(false); 
        		
        				
        	} else {
        		g1.setSelected(false);
      	        g2.setSelected(false); 
          		g3.setSelected(false);
          		g4.setSelected(true);
          		g5.setSelected(false);
          		g6.setSelected(false);
          		g7.setSelected(false); 
          		g8.setSelected(false);
          		g9.setSelected(false);
          		g10.setSelected(false);
          		g11.setSelected(false);
    	        g12.setSelected(false); 
        		g13.setSelected(false);
        		g14.setSelected(false);
        		g15.setSelected(false);
        		g16.setSelected(false);
        		g17.setSelected(false); 
        		g18.setSelected(false);
        		g19.setSelected(false);
        		g20.setSelected(false);
        		g21.setSelected(false);
    	        g22.setSelected(false); 
        		g23.setSelected(false);
        		g24.setSelected(false);
        		g25.setSelected(false);
        		g26.setSelected(false);
        		g27.setSelected(false); 
        		g28.setSelected(false);
        		g29.setSelected(false);
        		g30.setSelected(false);
      		b.callComm("4");
  	            //...Handled toggle on
  	        }
        	
         }
        
        
     });   
    
    g5.setOnClickListener(new View.OnClickListener() {
        public void onClick(View v) {
        	if (g5.isSelected()){
        		g5.setSelected(false); 
        		
        				
        	} else {
        		g1.setSelected(false);
      	        g2.setSelected(false); 
          		g3.setSelected(false);
          		g4.setSelected(false);
          		g5.setSelected(true);
          		g6.setSelected(false);
          		g7.setSelected(false); 
          		g8.setSelected(false);
          		g9.setSelected(false);
          		g10.setSelected(false);
          		g11.setSelected(false);
    	        g12.setSelected(false); 
        		g13.setSelected(false);
        		g14.setSelected(false);
        		g15.setSelected(false);
        		g16.setSelected(false);
        		g17.setSelected(false); 
        		g18.setSelected(false);
        		g19.setSelected(false);
        		g20.setSelected(false);
        		g21.setSelected(false);
    	        g22.setSelected(false); 
        		g23.setSelected(false);
        		g24.setSelected(false);
        		g25.setSelected(false);
        		g26.setSelected(false);
        		g27.setSelected(false); 
        		g28.setSelected(false);
        		g29.setSelected(false);
        		g30.setSelected(false);
      		b.callComm("5");
  	            //...Handled toggle on
  	        }
        	
         }
        
        
     });
    
    g6.setOnClickListener(new View.OnClickListener() {
        public void onClick(View v) {
        	if (g6.isSelected()){
        		g6.setSelected(false); 
        		
        				
        	} else {
        		g1.setSelected(false);
      	        g2.setSelected(false); 
          		g3.setSelected(false);
          		g4.setSelected(false);
          		g5.setSelected(false);
          		g6.setSelected(true);
          		g7.setSelected(false); 
          		g8.setSelected(false);
          		g9.setSelected(false);
          		g10.setSelected(false);
          		g11.setSelected(false);
    	        g12.setSelected(false); 
        		g13.setSelected(false);
        		g14.setSelected(false);
        		g15.setSelected(false);
        		g16.setSelected(false);
        		g17.setSelected(false); 
        		g18.setSelected(false);
        		g19.setSelected(false);
        		g20.setSelected(false);
        		g21.setSelected(false);
    	        g22.setSelected(false); 
        		g23.setSelected(false);
        		g24.setSelected(false);
        		g25.setSelected(false);
        		g26.setSelected(false);
        		g27.setSelected(false); 
        		g28.setSelected(false);
        		g29.setSelected(false);
        		g30.setSelected(false);
      		 b.callComm("6");
      		
  	            //...Handled toggle on
  	        }
        	
         }
        
        
     });

    g7.setOnClickListener(new View.OnClickListener() {
        public void onClick(View v) {
        	if (g7.isSelected()){
        		g7.setSelected(false); 
        		
        				
        	} else {
        		g1.setSelected(false);
      	        g2.setSelected(false); 
          		g3.setSelected(false);
          		g4.setSelected(false);
          		g5.setSelected(false);
          		g6.setSelected(false);
          		g7.setSelected(true); 
          		g8.setSelected(false);
          		g9.setSelected(false);
          		g10.setSelected(false);
          		g11.setSelected(false);
    	        g12.setSelected(false); 
        		g13.setSelected(false);
        		g14.setSelected(false);
        		g15.setSelected(false);
        		g16.setSelected(false);
        		g17.setSelected(false); 
        		g18.setSelected(false);
        		g19.setSelected(false);
        		g20.setSelected(false);
        		g21.setSelected(false);
    	        g22.setSelected(false); 
        		g23.setSelected(false);
        		g24.setSelected(false);
        		g25.setSelected(false);
        		g26.setSelected(false);
        		g27.setSelected(false); 
        		g28.setSelected(false);
        		g29.setSelected(false);
        		g30.setSelected(false);
      		 b.callComm("7");
      		
  	            //...Handled toggle on
  	        }
        	
         }
        
        
     });
    
    g8.setOnClickListener(new View.OnClickListener() {
        public void onClick(View v) {
        	if (g8.isSelected()){
        		g8.setSelected(false); 
        		
        				
        	} else {
        		g1.setSelected(false);
      	        g2.setSelected(false); 
          		g3.setSelected(false);
          		g4.setSelected(false);
          		g5.setSelected(false);
          		g6.setSelected(false);
          		g7.setSelected(false); 
          		g8.setSelected(true);
          		g9.setSelected(false);
          		g10.setSelected(false);
          		g11.setSelected(false);
    	        g12.setSelected(false); 
        		g13.setSelected(false);
        		g14.setSelected(false);
        		g15.setSelected(false);
        		g16.setSelected(false);
        		g17.setSelected(false); 
        		g18.setSelected(false);
        		g19.setSelected(false);
        		g20.setSelected(false);
        		g21.setSelected(false);
    	        g22.setSelected(false); 
        		g23.setSelected(false);
        		g24.setSelected(false);
        		g25.setSelected(false);
        		g26.setSelected(false);
        		g27.setSelected(false); 
        		g28.setSelected(false);
        		g29.setSelected(false);
        		g30.setSelected(false);
      		 b.callComm("8");
      		
  	            //...Handled toggle on
  	        }
        	
         }
        
        
     });
    
    g9.setOnClickListener(new View.OnClickListener() {
        public void onClick(View v) {
        	if (g9.isSelected()){
        		g9.setSelected(false); 
        		
        				
        	} else {
        		g1.setSelected(false);
      	        g2.setSelected(false); 
          		g3.setSelected(false);
          		g4.setSelected(false);
          		g5.setSelected(false);
          		g6.setSelected(false);
          		g7.setSelected(false); 
          		g8.setSelected(false);
          		g9.setSelected(true);
          		g10.setSelected(false);
          		g11.setSelected(false);
    	        g12.setSelected(false); 
        		g13.setSelected(false);
        		g14.setSelected(false);
        		g15.setSelected(false);
        		g16.setSelected(false);
        		g17.setSelected(false); 
        		g18.setSelected(false);
        		g19.setSelected(false);
        		g20.setSelected(false);
        		g21.setSelected(false);
    	        g22.setSelected(false); 
        		g23.setSelected(false);
        		g24.setSelected(false);
        		g25.setSelected(false);
        		g26.setSelected(false);
        		g27.setSelected(false); 
        		g28.setSelected(false);
        		g29.setSelected(false);
        		g30.setSelected(false);
      		 b.callComm("9");
      		
  	            //...Handled toggle on
  	        }
        	
         }
        
        
     });
    
    g10.setOnClickListener(new View.OnClickListener() {
        public void onClick(View v) {
        	if (g10.isSelected()){
        		g10.setSelected(false); 
        		
        				
        	} else {
        		g1.setSelected(false);
      	        g2.setSelected(false); 
          		g3.setSelected(false);
          		g4.setSelected(false);
          		g5.setSelected(false);
          		g6.setSelected(false);
          		g7.setSelected(false); 
          		g8.setSelected(false);
          		g9.setSelected(false);
          		g10.setSelected(true);
          		g11.setSelected(false);
    	        g12.setSelected(false); 
        		g13.setSelected(false);
        		g14.setSelected(false);
        		g15.setSelected(false);
        		g16.setSelected(false);
        		g17.setSelected(false); 
        		g18.setSelected(false);
        		g19.setSelected(false);
        		g20.setSelected(false);
        		g21.setSelected(false);
    	        g22.setSelected(false); 
        		g23.setSelected(false);
        		g24.setSelected(false);
        		g25.setSelected(false);
        		g26.setSelected(false);
        		g27.setSelected(false); 
        		g28.setSelected(false);
        		g29.setSelected(false);
        		g30.setSelected(false);
      		 b.callComm("0");
      		
  	            //...Handled toggle on
  	        }
        	
         }
        
        
     });
    
    g11.setOnClickListener(new View.OnClickListener() {
        public void onClick(View v) {
        	if (g11.isSelected()){
        		g11.setSelected(false); 
        		
        				
        	} else {
        		g1.setSelected(false);
      	        g2.setSelected(false); 
          		g3.setSelected(false);
          		g4.setSelected(false);
          		g5.setSelected(false);
          		g6.setSelected(false);
          		g7.setSelected(false); 
          		g8.setSelected(false);
          		g9.setSelected(false);
          		g10.setSelected(false);
          		g11.setSelected(true);
    	        g12.setSelected(false); 
        		g13.setSelected(false);
        		g14.setSelected(false);
        		g15.setSelected(false);
        		g16.setSelected(false);
        		g17.setSelected(false); 
        		g18.setSelected(false);
        		g19.setSelected(false);
        		g20.setSelected(false);
        		g21.setSelected(false);
    	        g22.setSelected(false); 
        		g23.setSelected(false);
        		g24.setSelected(false);
        		g25.setSelected(false);
        		g26.setSelected(false);
        		g27.setSelected(false); 
        		g28.setSelected(false);
        		g29.setSelected(false);
        		g30.setSelected(false);
      		 b.callComm("a");
      		
  	            //...Handled toggle on
  	        }
        	
         }
        
        
     });
        	
	          
    g12.setOnClickListener(new View.OnClickListener() {
        public void onClick(View v) {
        	if (g12.isSelected()){
        		g12.setSelected(false); 
        		
        				
        	} else {
        		g1.setSelected(false);
      	        g2.setSelected(false); 
          		g3.setSelected(false);
          		g4.setSelected(false);
          		g5.setSelected(false);
          		g6.setSelected(false);
          		g7.setSelected(false); 
          		g8.setSelected(false);
          		g9.setSelected(false);
          		g10.setSelected(false);
          		g11.setSelected(false);
    	        g12.setSelected(true); 
        		g13.setSelected(false);
        		g14.setSelected(false);
        		g15.setSelected(false);
        		g16.setSelected(false);
        		g17.setSelected(false); 
        		g18.setSelected(false);
        		g19.setSelected(false);
        		g20.setSelected(false);
        		g21.setSelected(false);
    	        g22.setSelected(false); 
        		g23.setSelected(false);
        		g24.setSelected(false);
        		g25.setSelected(false);
        		g26.setSelected(false);
        		g27.setSelected(false); 
        		g28.setSelected(false);
        		g29.setSelected(false);
        		g30.setSelected(false);
      		b.callComm("b");
  	            //...Handled toggle on
  	        }
        	
         }
        
        
     });
        

    g13.setOnClickListener(new View.OnClickListener() {
        public void onClick(View v) {
        	if (g13.isSelected()){
        		g13.setSelected(false); 
        		
        				
        	} else {
        		g1.setSelected(false);
      	        g2.setSelected(false); 
          		g3.setSelected(false);
          		g4.setSelected(false);
          		g5.setSelected(false);
          		g6.setSelected(false);
          		g7.setSelected(false); 
          		g8.setSelected(false);
          		g9.setSelected(false);
          		g10.setSelected(false);
          		g11.setSelected(false);
    	        g12.setSelected(false); 
        		g13.setSelected(true);
        		g14.setSelected(false);
        		g15.setSelected(false);
        		g16.setSelected(false);
        		g17.setSelected(false); 
        		g18.setSelected(false);
        		g19.setSelected(false);
        		g20.setSelected(false);
        		g21.setSelected(false);
    	        g22.setSelected(false); 
        		g23.setSelected(false);
        		g24.setSelected(false);
        		g25.setSelected(false);
        		g26.setSelected(false);
        		g27.setSelected(false); 
        		g28.setSelected(false);
        		g29.setSelected(false);
        		g30.setSelected(false);
      		b.callComm("c");
  	            //...Handled toggle on
  	        }
        	
         }
        
        
     });

    g14.setOnClickListener(new View.OnClickListener() {
        public void onClick(View v) {
        	if (g14.isSelected()){
        		g14.setSelected(false); 
        		
        				
        	} else {
        		g1.setSelected(false);
      	        g2.setSelected(false); 
          		g3.setSelected(false);
          		g4.setSelected(false);
          		g5.setSelected(false);
          		g6.setSelected(false);
          		g7.setSelected(false); 
          		g8.setSelected(false);
          		g9.setSelected(false);
          		g10.setSelected(false);
          		g11.setSelected(false);
    	        g12.setSelected(false); 
        		g13.setSelected(false);
        		g14.setSelected(true);
        		g15.setSelected(false);
        		g16.setSelected(false);
        		g17.setSelected(false); 
        		g18.setSelected(false);
        		g19.setSelected(false);
        		g20.setSelected(false);
        		g21.setSelected(false);
    	        g22.setSelected(false); 
        		g23.setSelected(false);
        		g24.setSelected(false);
        		g25.setSelected(false);
        		g26.setSelected(false);
        		g27.setSelected(false); 
        		g28.setSelected(false);
        		g29.setSelected(false);
        		g30.setSelected(false);
      		b.callComm("d");
  	            //...Handled toggle on
  	        }
        	
         }
        
        
     });   
    
    g15.setOnClickListener(new View.OnClickListener() {
        public void onClick(View v) {
        	if (g15.isSelected()){
        		g15.setSelected(false); 
        		
        				
        	} else {
        		g1.setSelected(false);
      	        g2.setSelected(false); 
          		g3.setSelected(false);
          		g4.setSelected(false);
          		g5.setSelected(false);
          		g6.setSelected(false);
          		g7.setSelected(false); 
          		g8.setSelected(false);
          		g9.setSelected(false);
          		g10.setSelected(false);
          		g11.setSelected(false);
    	        g12.setSelected(false); 
        		g13.setSelected(false);
        		g14.setSelected(false);
        		g15.setSelected(true);
        		g16.setSelected(false);
        		g17.setSelected(false); 
        		g18.setSelected(false);
        		g19.setSelected(false);
        		g20.setSelected(false);
        		g21.setSelected(false);
    	        g22.setSelected(false); 
        		g23.setSelected(false);
        		g24.setSelected(false);
        		g25.setSelected(false);
        		g26.setSelected(false);
        		g27.setSelected(false); 
        		g28.setSelected(false);
        		g29.setSelected(false);
        		g30.setSelected(false);
      		b.callComm("e");
  	            //...Handled toggle on
  	        }
        	
         }
        
        
     });
    
    g16.setOnClickListener(new View.OnClickListener() {
        public void onClick(View v) {
        	if (g16.isSelected()){
        		g16.setSelected(false); 
        		
        				
        	} else {
        		g1.setSelected(false);
      	        g2.setSelected(false); 
          		g3.setSelected(false);
          		g4.setSelected(false);
          		g5.setSelected(false);
          		g6.setSelected(false);
          		g7.setSelected(false); 
          		g8.setSelected(false);
          		g9.setSelected(false);
          		g10.setSelected(false);
          		g11.setSelected(false);
    	        g12.setSelected(false); 
        		g13.setSelected(false);
        		g14.setSelected(false);
        		g15.setSelected(false);
        		g16.setSelected(true);
        		g17.setSelected(false); 
        		g18.setSelected(false);
        		g19.setSelected(false);
        		g20.setSelected(false);
        		g21.setSelected(false);
    	        g22.setSelected(false); 
        		g23.setSelected(false);
        		g24.setSelected(false);
        		g25.setSelected(false);
        		g26.setSelected(false);
        		g27.setSelected(false); 
        		g28.setSelected(false);
        		g29.setSelected(false);
        		g30.setSelected(false);
      		 b.callComm("f");
      		
  	            //...Handled toggle on
  	        }
        	
         }
        
        
     });

    g17.setOnClickListener(new View.OnClickListener() {
        public void onClick(View v) {
        	if (g17.isSelected()){
        		g17.setSelected(false); 
        		
        				
        	} else {
        		g1.setSelected(false);
      	        g2.setSelected(false); 
          		g3.setSelected(false);
          		g4.setSelected(false);
          		g5.setSelected(false);
          		g6.setSelected(false);
          		g7.setSelected(false); 
          		g8.setSelected(false);
          		g9.setSelected(false);
          		g10.setSelected(false);
          		g11.setSelected(false);
    	        g12.setSelected(false); 
        		g13.setSelected(false);
        		g14.setSelected(false);
        		g15.setSelected(false);
        		g16.setSelected(false);
        		g17.setSelected(true); 
        		g18.setSelected(false);
        		g19.setSelected(false);
        		g20.setSelected(false);
        		g21.setSelected(false);
    	        g22.setSelected(false); 
        		g23.setSelected(false);
        		g24.setSelected(false);
        		g25.setSelected(false);
        		g26.setSelected(false);
        		g27.setSelected(false); 
        		g28.setSelected(false);
        		g29.setSelected(false);
        		g30.setSelected(false);
      		 b.callComm("g");
      		
  	            //...Handled toggle on
  	        }
        	
         }
        
        
     });
    
    g18.setOnClickListener(new View.OnClickListener() {
        public void onClick(View v) {
        	if (g18.isSelected()){
        		g18.setSelected(false); 
        		
        				
        	} else {
        		g1.setSelected(false);
      	        g2.setSelected(false); 
          		g3.setSelected(false);
          		g4.setSelected(false);
          		g5.setSelected(false);
          		g6.setSelected(false);
          		g7.setSelected(false); 
          		g8.setSelected(false);
          		g9.setSelected(false);
          		g10.setSelected(false);
          		g11.setSelected(false);
    	        g12.setSelected(false); 
        		g13.setSelected(false);
        		g14.setSelected(false);
        		g15.setSelected(false);
        		g16.setSelected(false);
        		g17.setSelected(false); 
        		g18.setSelected(true);
        		g19.setSelected(false);
        		g20.setSelected(false);
        		g21.setSelected(false);
    	        g22.setSelected(false); 
        		g23.setSelected(false);
        		g24.setSelected(false);
        		g25.setSelected(false);
        		g26.setSelected(false);
        		g27.setSelected(false); 
        		g28.setSelected(false);
        		g29.setSelected(false);
        		g30.setSelected(false);
      		 b.callComm("h");
      		
  	            //...Handled toggle on
  	        }
        	
         }
        
        
     });
    
    g19.setOnClickListener(new View.OnClickListener() {
        public void onClick(View v) {
        	if (g19.isSelected()){
        		g19.setSelected(false); 
        		
        				
        	} else {
        		g1.setSelected(false);
      	        g2.setSelected(false); 
          		g3.setSelected(false);
          		g4.setSelected(false);
          		g5.setSelected(false);
          		g6.setSelected(false);
          		g7.setSelected(false); 
          		g8.setSelected(false);
          		g9.setSelected(false);
          		g10.setSelected(false);
          		g11.setSelected(false);
    	        g12.setSelected(false); 
        		g13.setSelected(false);
        		g14.setSelected(false);
        		g15.setSelected(false);
        		g16.setSelected(false);
        		g17.setSelected(false); 
        		g18.setSelected(false);
        		g19.setSelected(true);
        		g20.setSelected(false);
        		g21.setSelected(false);
    	        g22.setSelected(false); 
        		g23.setSelected(false);
        		g24.setSelected(false);
        		g25.setSelected(false);
        		g26.setSelected(false);
        		g27.setSelected(false); 
        		g28.setSelected(false);
        		g29.setSelected(false);
        		g30.setSelected(false);
      		 b.callComm("i");
      		
  	            //...Handled toggle on
  	        }
        	
         }
        
        
     });
    
    g20.setOnClickListener(new View.OnClickListener() {
        public void onClick(View v) {
        	if (g20.isSelected()){
        		g20.setSelected(false); 
        		
        				
        	} else {
        		g1.setSelected(false);
      	        g2.setSelected(false); 
          		g3.setSelected(false);
          		g4.setSelected(false);
          		g5.setSelected(false);
          		g6.setSelected(false);
          		g7.setSelected(false); 
          		g8.setSelected(false);
          		g9.setSelected(false);
          		g10.setSelected(false);
          		g11.setSelected(false);
    	        g12.setSelected(false); 
        		g13.setSelected(false);
        		g14.setSelected(false);
        		g15.setSelected(false);
        		g16.setSelected(false);
        		g17.setSelected(false); 
        		g18.setSelected(false);
        		g19.setSelected(false);
        		g20.setSelected(true);
        		g21.setSelected(false);
    	        g22.setSelected(false); 
        		g23.setSelected(false);
        		g24.setSelected(false);
        		g25.setSelected(false);
        		g26.setSelected(false);
        		g27.setSelected(false); 
        		g28.setSelected(false);
        		g29.setSelected(false);
        		g30.setSelected(false);
      		 b.callComm("j");
      		
  	            //...Handled toggle on
  	        }
        	
         }
        
        
     });
    
    g21.setOnClickListener(new View.OnClickListener() {
        public void onClick(View v) {
        	if (g21.isSelected()){
        		g21.setSelected(false); 
        		
        				
        	} else {
        		g1.setSelected(false);
      	        g2.setSelected(false); 
          		g3.setSelected(false);
          		g4.setSelected(false);
          		g5.setSelected(false);
          		g6.setSelected(false);
          		g7.setSelected(false); 
          		g8.setSelected(false);
          		g9.setSelected(false);
          		g10.setSelected(false);
          		g11.setSelected(false);
    	        g12.setSelected(false); 
        		g13.setSelected(false);
        		g14.setSelected(false);
        		g15.setSelected(false);
        		g16.setSelected(false);
        		g17.setSelected(false); 
        		g18.setSelected(false);
        		g19.setSelected(false);
        		g20.setSelected(false);
        		g21.setSelected(true);
    	        g22.setSelected(false); 
        		g23.setSelected(false);
        		g24.setSelected(false);
        		g25.setSelected(false);
        		g26.setSelected(false);
        		g27.setSelected(false); 
        		g28.setSelected(false);
        		g29.setSelected(false);
        		g30.setSelected(false);
      		 b.callComm("k");
      		
  	            //...Handled toggle on
  	        }
        	
         }
        
        
     });
        	
	          
    g22.setOnClickListener(new View.OnClickListener() {
        public void onClick(View v) {
        	if (g22.isSelected()){
        		g22.setSelected(false); 
        		
        				
        	} else {
        		g1.setSelected(false);
      	        g2.setSelected(false); 
          		g3.setSelected(false);
          		g4.setSelected(false);
          		g5.setSelected(false);
          		g6.setSelected(false);
          		g7.setSelected(false); 
          		g8.setSelected(false);
          		g9.setSelected(false);
          		g10.setSelected(false);
          		g11.setSelected(false);
    	        g12.setSelected(false); 
        		g13.setSelected(false);
        		g14.setSelected(false);
        		g15.setSelected(false);
        		g16.setSelected(false);
        		g17.setSelected(false); 
        		g18.setSelected(false);
        		g19.setSelected(false);
        		g20.setSelected(false);
        		g21.setSelected(false);
    	        g22.setSelected(true); 
        		g23.setSelected(false);
        		g24.setSelected(false);
        		g25.setSelected(false);
        		g26.setSelected(false);
        		g27.setSelected(false); 
        		g28.setSelected(false);
        		g29.setSelected(false);
        		g30.setSelected(false);
      		b.callComm("l");
  	            //...Handled toggle on
  	        }
        	
         }
        
        
     });
        

    g23.setOnClickListener(new View.OnClickListener() {
        public void onClick(View v) {
        	if (g23.isSelected()){
        		g23.setSelected(false); 
        		
        				
        	} else {
        		g1.setSelected(false);
      	        g2.setSelected(false); 
          		g3.setSelected(false);
          		g4.setSelected(false);
          		g5.setSelected(false);
          		g6.setSelected(false);
          		g7.setSelected(false); 
          		g8.setSelected(false);
          		g9.setSelected(false);
          		g10.setSelected(false);
          		g11.setSelected(false);
    	        g12.setSelected(false); 
        		g13.setSelected(false);
        		g14.setSelected(false);
        		g15.setSelected(false);
        		g16.setSelected(false);
        		g17.setSelected(false); 
        		g18.setSelected(false);
        		g19.setSelected(false);
        		g20.setSelected(false);
        		g21.setSelected(false);
    	        g22.setSelected(false); 
        		g23.setSelected(true);
        		g24.setSelected(false);
        		g25.setSelected(false);
        		g26.setSelected(false);
        		g27.setSelected(false); 
        		g28.setSelected(false);
        		g29.setSelected(false);
        		g30.setSelected(false);
      		b.callComm("m");
  	            //...Handled toggle on
  	        }
        	
         }
        
        
     });

    g24.setOnClickListener(new View.OnClickListener() {
        public void onClick(View v) {
        	if (g24.isSelected()){
        		g24.setSelected(false); 
        		
        				
        	} else {
        		g1.setSelected(false);
      	        g2.setSelected(false); 
          		g3.setSelected(false);
          		g4.setSelected(false);
          		g5.setSelected(false);
          		g6.setSelected(false);
          		g7.setSelected(false); 
          		g8.setSelected(false);
          		g9.setSelected(false);
          		g10.setSelected(false);
          		g11.setSelected(false);
    	        g12.setSelected(false); 
        		g13.setSelected(false);
        		g14.setSelected(false);
        		g15.setSelected(false);
        		g16.setSelected(false);
        		g17.setSelected(false); 
        		g18.setSelected(false);
        		g19.setSelected(false);
        		g20.setSelected(false);
        		g21.setSelected(false);
    	        g22.setSelected(false); 
        		g23.setSelected(false);
        		g24.setSelected(true);
        		g25.setSelected(false);
        		g26.setSelected(false);
        		g27.setSelected(false); 
        		g28.setSelected(false);
        		g29.setSelected(false);
        		g30.setSelected(false);
      		b.callComm("n");
  	            //...Handled toggle on
  	        }
        	
         }
        
        
     });   
    
    g25.setOnClickListener(new View.OnClickListener() {
        public void onClick(View v) {
        	if (g25.isSelected()){
        		g25.setSelected(false); 
        		
        				
        	} else {
        		g1.setSelected(false);
      	        g2.setSelected(false); 
          		g3.setSelected(false);
          		g4.setSelected(false);
          		g5.setSelected(false);
          		g6.setSelected(false);
          		g7.setSelected(false); 
          		g8.setSelected(false);
          		g9.setSelected(false);
          		g10.setSelected(false);
          		g11.setSelected(false);
    	        g12.setSelected(false); 
        		g13.setSelected(false);
        		g14.setSelected(false);
        		g15.setSelected(false);
        		g16.setSelected(false);
        		g17.setSelected(false); 
        		g18.setSelected(false);
        		g19.setSelected(false);
        		g20.setSelected(false);
        		g21.setSelected(false);
    	        g22.setSelected(false); 
        		g23.setSelected(false);
        		g24.setSelected(false);
        		g25.setSelected(true);
        		g26.setSelected(false);
        		g27.setSelected(false); 
        		g28.setSelected(false);
        		g29.setSelected(false);
        		g30.setSelected(false);
      		b.callComm("o");
  	            //...Handled toggle on
  	        }
        	
         }
        
        
     });
    
    g26.setOnClickListener(new View.OnClickListener() {
        public void onClick(View v) {
        	if (g26.isSelected()){
        		g26.setSelected(false); 
        		
        				
        	} else {
        		g1.setSelected(false);
      	        g2.setSelected(false); 
          		g3.setSelected(false);
          		g4.setSelected(false);
          		g5.setSelected(false);
          		g6.setSelected(false);
          		g7.setSelected(false); 
          		g8.setSelected(false);
          		g9.setSelected(false);
          		g10.setSelected(false);
          		g11.setSelected(false);
    	        g12.setSelected(false); 
        		g13.setSelected(false);
        		g14.setSelected(false);
        		g15.setSelected(false);
        		g16.setSelected(false);
        		g17.setSelected(false); 
        		g18.setSelected(false);
        		g19.setSelected(false);
        		g20.setSelected(false);
        		g21.setSelected(false);
    	        g22.setSelected(false); 
        		g23.setSelected(false);
        		g24.setSelected(false);
        		g25.setSelected(false);
        		g26.setSelected(true);
        		g27.setSelected(false); 
        		g28.setSelected(false);
        		g29.setSelected(false);
        		g30.setSelected(false);
      		 b.callComm("p");
      		
  	            //...Handled toggle on
  	        }
        	
         }
        
        
     });

    g27.setOnClickListener(new View.OnClickListener() {
        public void onClick(View v) {
        	if (g27.isSelected()){
        		g27.setSelected(false); 
        		
        				
        	} else {
        		g1.setSelected(false);
      	        g2.setSelected(false); 
          		g3.setSelected(false);
          		g4.setSelected(false);
          		g5.setSelected(false);
          		g6.setSelected(false);
          		g7.setSelected(false); 
          		g8.setSelected(false);
          		g9.setSelected(false);
          		g10.setSelected(false);
          		g11.setSelected(false);
    	        g12.setSelected(false); 
        		g13.setSelected(false);
        		g14.setSelected(false);
        		g15.setSelected(false);
        		g16.setSelected(false);
        		g17.setSelected(false); 
        		g18.setSelected(false);
        		g19.setSelected(false);
        		g20.setSelected(false);
        		g21.setSelected(false);
    	        g22.setSelected(false); 
        		g23.setSelected(false);
        		g24.setSelected(false);
        		g25.setSelected(false);
        		g26.setSelected(false);
        		g27.setSelected(true); 
        		g28.setSelected(false);
        		g29.setSelected(false);
        		g30.setSelected(false);
      		 b.callComm("q");
      		
  	            //...Handled toggle on
  	        }
        	
         }
        
        
     });
    
    g28.setOnClickListener(new View.OnClickListener() {
        public void onClick(View v) {
        	if (g28.isSelected()){
        		g28.setSelected(false); 
        		
        				
        	} else {
        		g1.setSelected(false);
      	        g2.setSelected(false); 
          		g3.setSelected(false);
          		g4.setSelected(false);
          		g5.setSelected(false);
          		g6.setSelected(false);
          		g7.setSelected(false); 
          		g8.setSelected(false);
          		g9.setSelected(false);
          		g10.setSelected(false);
          		g11.setSelected(false);
    	        g12.setSelected(false); 
        		g13.setSelected(false);
        		g14.setSelected(false);
        		g15.setSelected(false);
        		g16.setSelected(false);
        		g17.setSelected(false); 
        		g18.setSelected(false);
        		g19.setSelected(false);
        		g20.setSelected(false);
        		g21.setSelected(false);
    	        g22.setSelected(false); 
        		g23.setSelected(false);
        		g24.setSelected(false);
        		g25.setSelected(false);
        		g26.setSelected(false);
        		g27.setSelected(false); 
        		g28.setSelected(true);
        		g29.setSelected(false);
        		g30.setSelected(false);
      		 b.callComm("r");
      		
  	            //...Handled toggle on
  	        }
        	
         }
        
        
     });
    
    g29.setOnClickListener(new View.OnClickListener() {
        public void onClick(View v) {
        	if (g29.isSelected()){
        		g29.setSelected(false); 
        		
        				
        	} else {
        		g1.setSelected(false);
      	        g2.setSelected(false); 
          		g3.setSelected(false);
          		g4.setSelected(false);
          		g5.setSelected(false);
          		g6.setSelected(false);
          		g7.setSelected(false); 
          		g8.setSelected(false);
          		g9.setSelected(false);
          		g10.setSelected(false);
          		g11.setSelected(false);
    	        g12.setSelected(false); 
        		g13.setSelected(false);
        		g14.setSelected(false);
        		g15.setSelected(false);
        		g16.setSelected(false);
        		g17.setSelected(false); 
        		g18.setSelected(false);
        		g19.setSelected(false);
        		g20.setSelected(false);
        		g21.setSelected(false);
    	        g22.setSelected(false); 
        		g23.setSelected(false);
        		g24.setSelected(false);
        		g25.setSelected(false);
        		g26.setSelected(false);
        		g27.setSelected(false); 
        		g28.setSelected(false);
        		g29.setSelected(true);
        		g30.setSelected(false);
      		 b.callComm("s");
      		
  	            //...Handled toggle on
  	        }
        	
         }
        
        
     });
    
    g30.setOnClickListener(new View.OnClickListener() {
        public void onClick(View v) {
        	if (g30.isSelected()){
        		g30.setSelected(false); 
        		
        				
        	} else {
        		g1.setSelected(false);
      	        g2.setSelected(false); 
          		g3.setSelected(false);
          		g4.setSelected(false);
          		g5.setSelected(false);
          		g6.setSelected(false);
          		g7.setSelected(false); 
          		g8.setSelected(false);
          		g9.setSelected(false);
          		g10.setSelected(false);
          		g11.setSelected(false);
    	        g12.setSelected(false); 
        		g13.setSelected(false);
        		g14.setSelected(false);
        		g15.setSelected(false);
        		g16.setSelected(false);
        		g17.setSelected(false); 
        		g18.setSelected(false);
        		g19.setSelected(false);
        		g20.setSelected(false);
        		g21.setSelected(false);
    	        g22.setSelected(false); 
        		g23.setSelected(false);
        		g24.setSelected(false);
        		g25.setSelected(false);
        		g26.setSelected(false);
        		g27.setSelected(false); 
        		g28.setSelected(false);
        		g29.setSelected(false);
        		g30.setSelected(true);
      		 b.callComm("t");
      		
  	            //...Handled toggle on
  	        }
        	
         }
        
        
     });
}
}


